package cn.ichiva.web.component;

import cn.ichiva.web.common.Bus;
import cn.ichiva.web.common.Topic;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.layout.HBox;

import java.awt.*;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

public class TabBar implements Initializable {
    List<String> labelList = new ArrayList<>();

    public TabBar(){
        labelList.add("");
    }

    @FXML
    HBox root;

    @FXML
    public void home(){
        Bus.publish(Topic.Home,null);
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        labelList.forEach(url -> addLabel("默认title",url));
    }

    public void addLabel(String title, String url){
        root.getChildren().add(new TabBarLabel(title,url));
    }

    public void removeLabel(String url){

    }

}
